home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / MDI.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  5KB  |  201 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.4  $
  6. //
  7. // Definition of TMDIClient and TMDIFrame classes
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_MDI_H)
  10. #define OWL_MDI_H
  11.  
  12. #if !defined(OWL_FRAMEWIN_H)
  13. # include <owl/framewin.h>
  14. #endif
  15. #if !defined(OWL_MDICHILD_H)
  16. # include <owl/mdichild.h>
  17. #endif
  18. #include <owl/mdi.rh>
  19.  
  20. // Generic definitions/compiler options (eg. alignment) preceeding the 
  21. // definition of classes
  22. #include <services/preclass.h>
  23.  
  24. #if defined(BI_NAMESPACE)
  25. namespace OWL {
  26. #endif
  27.  
  28. class _OWLCLASS TMDIFrame;
  29.  
  30. //
  31. // class TMDIClient
  32. // ~~~~~ ~~~~~~~~~~
  33. class _OWLCLASS TMDIClient : public virtual TWindow {
  34.   public:
  35.     TMDIClient(TModule* module = 0);
  36.    ~TMDIClient();
  37.  
  38.     virtual bool        CloseChildren();
  39.     TMDIChild*          GetActiveMDIChild();
  40.  
  41.     // Member functions to arrange the MDI children
  42.     //
  43.     virtual void        ArrangeIcons();
  44.     virtual void        CascadeChildren();
  45.     virtual void        TileChildren(int tile = MDITILE_VERTICAL);
  46.  
  47.     // Override member functions defined by TWindow
  48.     //
  49.     bool                PreProcessMsg(MSG& msg);
  50.     bool                Create();
  51.  
  52.     virtual TWindow*    CreateChild();
  53.  
  54.     // Constructs a new MDI child window object. By default, constructs an
  55.     // instance of TWindow as an MDI child window object
  56.     //
  57.     virtual TMDIChild*  InitChild();
  58.  
  59.     LPCLIENTCREATESTRUCT  GetClientAttr();
  60.     void   SetClientAttr(LPCLIENTCREATESTRUCT clientattr);
  61.  
  62.   protected:
  63.     char far*           GetClassName();
  64.  
  65.     // Menu command handlers & enabler
  66.     //
  67.     void                CmCreateChild();        // CM_CREATECHILD
  68.     void                CmTileChildren();       // CM_TILECHILDREN
  69.     void                CmTileChildrenHoriz();  // CM_TILECHILDREN
  70.     void                CmCascadeChildren();    // CM_CASCADECHILDREN
  71.     void                CmArrangeIcons();       // CM_ARRANGEICONS
  72.     void                CmCloseChildren();      // CM_CLOSECHILDREN
  73.     void                CmChildActionEnable(TCommandEnabler& commandEnabler);
  74.  
  75.     TResult             EvMDICreate(MDICREATESTRUCT far& createStruct);
  76.     void                EvMDIDestroy(HWND hWnd);
  77.  
  78.     void                EvDropFiles(TDropInfo);
  79.  
  80.   public_data:
  81.     LPCLIENTCREATESTRUCT  ClientAttr;
  82.  
  83.   private:
  84.     TMDIClient(HWND hWnd, TModule*   module = 0);
  85.  
  86.     // Hidden to prevent accidental copying or assignment
  87.     //
  88.     TMDIClient(const TMDIClient&);
  89.     TMDIClient& operator =(const TMDIClient&);
  90.  
  91.   DECLARE_RESPONSE_TABLE(TMDIClient);
  92.   DECLARE_STREAMABLE(_OWLCLASS, TMDIClient, 1);
  93.   friend class TMDIFrame;  // To allow access to private ctor
  94. };
  95.  
  96. typedef TMDIClient TMdiClient;
  97.  
  98. //
  99. // class TMDIFrame
  100. // ~~~~~ ~~~~~~~~~
  101. class _OWLCLASS TMDIFrame : virtual public TFrameWindow {
  102.   public:
  103.     TMDIFrame(const char far* title,
  104.               TResId          menuResId,
  105.               TMDIClient&     clientWnd = *new TMDIClient,
  106.               TModule*        module = 0);
  107.  
  108.  
  109.     TMDIFrame(THandle frameHandle, HWND clientHandle, TModule* module = 0);
  110.  
  111.     // Override virtual functions defined by TFrameWindow or TWindow
  112.     //
  113.     bool         SetMenu(HMENU);
  114. #if defined(BI_NO_COVAR_RET)
  115.     TWindow*     GetClientWindow();
  116. #else
  117.     TMDIClient*  GetClientWindow();
  118. #endif
  119.     virtual HWND GetCommandTarget();
  120.     void         PerformCreate(int menuOrId);
  121.  
  122.     // Find & return the child menu of an MDI frame's (or anyone's) menu bar.
  123.     //
  124.     static HMENU FindChildMenu(HMENU);
  125.  
  126.   protected:
  127.     // Override to call ::DefFrameProc() instead of ::DefWindowProc()
  128.     //
  129.     TResult      DefWindowProc(uint message, TParam1 param1, TParam2 param2);
  130.  
  131.   private:
  132.     // Hidden to prevent accidental copying or assignment
  133.     //
  134.     TMDIFrame(const TMDIFrame&);
  135.     TMDIFrame& operator=(const TMDIFrame&);
  136.  
  137.   DECLARE_RESPONSE_TABLE(TMDIFrame);
  138.   DECLARE_STREAMABLE(_OWLCLASS, TMDIFrame, 1);
  139. };
  140.  
  141. typedef TMDIFrame TMdiFrame;
  142.  
  143. // Generic definitions/compiler options (eg. alignment) following the 
  144. // definition of classes
  145. #include <services/posclass.h>
  146.  
  147. #if defined(BI_NAMESPACE)
  148. } // namespace OWL
  149. #endif
  150.  
  151. //----------------------------------------------------------------------------
  152. // Inline implementations
  153. //
  154.  
  155. //
  156. // Return the client create struct for the MDI client.
  157. //
  158. inline LPCLIENTCREATESTRUCT TMDIClient::GetClientAttr() {
  159.   return ClientAttr;
  160. }
  161.  
  162. //
  163. // Set the client create struct for the MDI client.
  164. //
  165. inline void TMDIClient::SetClientAttr(LPCLIENTCREATESTRUCT clientattr) {
  166.   ClientAttr = clientattr;
  167. }
  168.  
  169. //
  170. inline void TMDIClient::CmCreateChild() {
  171.   CreateChild();
  172. }
  173.  
  174. //
  175. inline void TMDIClient::CmTileChildren() {
  176.   TileChildren();
  177. }
  178.  
  179. //
  180. inline void TMDIClient::CmTileChildrenHoriz() {
  181.   TileChildren(MDITILE_HORIZONTAL);
  182. }
  183.  
  184. //
  185. inline void TMDIClient::CmCascadeChildren() {
  186.   CascadeChildren();
  187. }
  188.  
  189. //
  190. inline void TMDIClient::CmArrangeIcons() {
  191.   ArrangeIcons();
  192. }
  193.  
  194. //
  195. inline void TMDIClient::CmCloseChildren() {
  196.   CloseChildren();
  197. }
  198.  
  199.  
  200. #endif  // OWL_MDI_H
  201.